import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 教师信息信息 */
export interface Teacher {
          teacherId: number; // 教师唯一ID (注意：前端number类型可以处理Long)
          deptName?: number; // 部门名称
          teacherName?: string; // 姓名
          teacherNo?: string; // 工号（OA）
          position?: string; // 职务
          gender?: number; // 性别（1男 2女）
          age?: number; // 年龄
          maritalStatus?: number; // 婚否（1已婚 0未婚）
          ethnicity?: string; // 民族
          idCard?: string; // 身份证号
          birthDate?: string; // 出生日期
          contactPhone?: string; // 联系方式
          entryDate?: string; // 入职日期
          entryYear?: number; // 入职年份
          entryMonth?: number; // 入职月份
          serviceYears?: number; // 已满年限
          householdType?: string; // 户口类型
          nativePlace?: string; // 籍贯
          householdAddress?: string; // 户籍地址
          currentAddress?: string; // 现住地址
          educationLevel?: string; // 学历
          major?: string; // 专业
          graduateSchool?: string; // 毕业学校
          professionalCertificate?: string; // 专业证书
          teachingCertificateNo?: string; // 教资证书编码
          certificateIssuer?: string; // 颁发单位
          certificateIssueDate?: string; // 颁发日期
          contractCount?: number; // 签合同次数
          contractSignDate?: string; // 签订合同
          contractExpireDate?: string; // 合同到期
          socialInsurance?: string; // 社保
          emergencyContact?: string; // 紧急联系
          personalEmail?: string; // 个人E-MAIL
          qqNumber?: string; // QQ号
          politicalStatus?: string; // 政治面貌
          personnelChanges?: string; // 人事异动
          hobbiesSpecialties?: string; // 爱好及特长
          graduationDate?: string; // 毕业时间
          professionalLevel?: string; // 职业等级
          professionalTitle?: string; // 职称
  }

// 教师信息 API
export const TeacherApi = {
  // 查询教师信息分页
  getTeacherPage: async (params: any) => {
    return await request.get({ url: `/ao/teacher/page`, params })
  },

  // 查询教师信息详情
  getTeacher: async (id: number) => {
    return await request.get({ url: `/ao/teacher/get?id=` + id })
  },

  // 新增教师信息
  createTeacher: async (data: Teacher) => {
    return await request.post({ url: `/ao/teacher/create`, data })
  },

  // 修改教师信息
  updateTeacher: async (data: Teacher) => {
    return await request.put({ url: `/ao/teacher/update`, data })
  },

  // 删除教师信息
  deleteTeacher: async (id: number) => {
    return await request.delete({ url: `/ao/teacher/delete?id=` + id })
  },

  /** 批量删除教师信息 */
  deleteTeacherList: async (ids: number[]) => {
    return await request.delete({ url: `/ao/teacher/delete-list?ids=${ids.join(',')}` })
  },

  // 导出教师信息 Excel
  exportTeacher: async (params) => {
    return await request.download({ url: `/ao/teacher/export-excel`, params })
  },

  // 获取教师的所有课程
  getTeacherCourses: async (teacherId: number) => {
    return await request.get({ url: `/ao/teacher/courses?teacherId=` + teacherId })
  },

  // 根据教师姓名获取所有课程
  getTeacherCoursesByName: async (teacherName: string) => {
    return await request.get({ url: `/ao/teacher/courses-by-name?teacherName=` + encodeURIComponent(teacherName) })
  },

  // 获取教师课程表
  getTeacherSchedule: async (teacherId: number) => {
    return await request.get({ url: `/ao/teacher/schedule?teacherId=` + teacherId })
  },

  // 获得导入教师信息模板
  importTeacherTemplate: async () => {
    return await request.download({ url: `/ao/teacher/get-import-template` })
  },

  // 导入教师信息
  importTeacher: async (data: FormData) => {
    return await request.upload({ url: `/ao/teacher/import`, data })
  },

  // 获取简单教师列表（用于下拉框）
  getSimpleTeacherList: async () => {
    return await request.get({ url: `/ao/teacher/simple-list` })
  },
}
